<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<script type="text/javascript">
	function jobChangeStatus(status) {
		var id = jobGrid.selrow();

		if (id) {
			$.post("app/job/changeStatus", {
				id : id,
				status : status
			}, function(data) {
				if (data.success == false) {
					isperp.alert(data.data);
				}
				jobGrid.reload();
			});
		} else {
			isperp.alert("请选择一条数据！");
		}
	}
	function statusFormatter(cellvalue) {
		if (cellvalue == 'run')
			return "<img title='运行' src='img/icons/packs/fugue/24x24/tick.png'>";
		else if (cellvalue == 'running')
			return "<img title='正在启动中' src='img/icons/packs/fugue/24x24/play.png'>";
		else if (cellvalue == 'stopping')
			return "<img title='正在停止中' src='img/icons/packs/fugue/24x24/stopping.png'>";
		else
			return "<img title='停止' src='img/icons/packs/fugue/24x24/minus-circle.png'>";

	}
</script>
<div class="container_0 clearfix">
	<div class="box no-border">
		<div class="header">
			<h2>${pageTitle}</h2>
		</div>
		<isperp:grid url="app/job/list" gridId="jobGrid"
			gridTitle="${pageTitle}" cusFormatterActions="true"
			showSearchbar="false" cusEditUrl="app/job/edit"
			ondbClickRowEvent="jobGrid.edit(rowid);"
			cusDeleteUrl="app/job/delete">

			<jsp:attribute name="toolbar">
			<isperp:toolbar id="jobToolbar">
				<isperp:button icon="icon-plus" text="新增"
						onclick="jobGrid.create();"></isperp:button>

				<isperp:button icon="icon-play" text="启动"
						onclick="jobChangeStatus('running');"></isperp:button>

				<isperp:button icon="icon-stop" text="停止"
						onclick="jobChangeStatus('stopping');"></isperp:button>
			</isperp:toolbar>
			</jsp:attribute>

			<jsp:body>
				<isperp:column name="id" title="id" hidden="true"></isperp:column>
				 
				<isperp:column name="name" title="名称" width="120">
				</isperp:column>
				<isperp:column name="beanId" title="beanId" width="150">
				</isperp:column>
				<isperp:column name="cronExpression" title="运行表达式" width="150">
				</isperp:column>
				<isperp:column name="description" title="描述" width="200">
				</isperp:column>
				<isperp:column name="status" title="运行状态" align="center"
					isFormatterFun="true" formatter="return statusFormatter(cellvalue)"
					width="50">
				</isperp:column>
			</jsp:body>
		</isperp:grid>
	</div>

</div>

